// 栗子

// 引入API
import { addFlower, getFlowerList, modifyFlower, removeFlower } from '@/api/api'

// actions中使用API
const flowerModule = {
    actions: {
        // 添加鲜花
        doAddFlower(context,flower) {
            return new Promise((resolve,reject) => {
                addFlower(flower)
                .then(res => resolve(res))
                .catch(err => reject(err))
            })
        },
        // 删除鲜花
        doRemoveFlower(context, id) {
            return new Promise((resolve, reject) => {
                removeFlower(id)
                .then(res => resolve(res))
                .catch(err => reject(err))
            })
        },
        // 修改
        doModifyFlower(context,flower) {
            return new Promise((resolve,reject) => {
                modifyFlower(flower)
                .then(res => resolve(res))
                .catch(err => reject(err))
            })
        },
        // 删除
        doGetFlowerList(context,data) {
            return new Promise((resolve, reject) => {
                getFlowerList(data)
                    .then(res => resolve(res))
                    .catch(err => reject(err))
            })
        }
    }
}

// 导出actions
export default flowerModule